using ASP;
using HoWave.Common;
using HoWave.Web;
using HoWave.Web.Admin;
using System;
using System.Collections;
using System.Data;
using System.Text;
using System.Web.Profile;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Xml;
public class HL_Admin_Admin_ShowDeliverType : Admin, IRequiresSessionState
{
	private Shop_DeliverType _shop_deliverType = null;
	private int _deliverTypeID = 0;
	private ArrayList al = new ArrayList();
	protected ScriptManager ScriptManager1;
	protected HtmlGenericControl deliverTypeInfo;
	protected Shop_DeliverType shop_deliverType
	{
		get
		{
			Shop_DeliverType shop_deliverType;
			if (this._shop_deliverType == null)
			{
				this._shop_deliverType = new Shop_DeliverType(this.conn);
				shop_deliverType = this._shop_deliverType;
			}
			else
			{
				shop_deliverType = this._shop_deliverType;
			}
			return shop_deliverType;
		}
	}
	protected int deliverTypeID
	{
		get
		{
			this._deliverTypeID = int.Parse(Fetch.Get("TypeID"));
			return this._deliverTypeID;
		}
	}
	protected DefaultProfile Profile
	{
		get
		{
			return (DefaultProfile)this.Context.Profile;
		}
	}
	protected global_asax ApplicationInstance
	{
		get
		{
			return (global_asax)this.Context.ApplicationInstance;
		}
	}
	protected void Page_Load(object sender, EventArgs e)
	{
		if (!base.admin.CheckAdminPower(31))
		{
			base.WriteLog("View", Language.GetAdminMsg("Log/Access", "0"), "PayType");
			base.WriteRightErrMsg();
		}
		this.bindlist();
	}
	private void bindlist()
	{
		DataTable deliverTypeByID = this.shop_deliverType.GetDeliverTypeByID(this.deliverTypeID);
		string xMLDeliverToGridView = this.GetXMLDeliverToGridView((string)deliverTypeByID.Rows[0]["DeliverAraa"], this.deliverTypeID.ToString(), (string)deliverTypeByID.Rows[0]["Intro"]);
		this.deliverTypeInfo.InnerHtml = xMLDeliverToGridView;
	}
	protected string GetXMLDeliverToGridView(string DeliverTemplate, string DeliverID, string Intro)
	{
		StringBuilder stringBuilder = new StringBuilder();
		string result;
		if (DeliverTemplate != "")
		{
			XmlDocument xmlDocument = new XmlDocument();
			xmlDocument.LoadXml(DeliverTemplate);
			XmlNodeList xmlNodeList = xmlDocument.SelectNodes("root/project");
			if (xmlNodeList == null)
			{
				result = "";
				return result;
			}
			foreach (XmlNode xmlNode in xmlNodeList)
			{
				string value = xmlNode.Attributes["name"].Value;
				string value2 = xmlNode.Attributes["lastupdate"].Value;
				XmlNodeList xmlNodeList2 = xmlNode.SelectNodes("deliver");
				stringBuilder.Append("<table class='adminlist' cellspacing=\"0\" cellpadding=\"0\">");
				stringBuilder.AppendFormat("<caption><span>{0}</span><em>最后编辑时间：{2}</em></caption>", value, DeliverID, value2);
				stringBuilder.Append("<tr><th>运送方式</th><th>运送到</th><th>运费</th><th>每增加一件商品</th></tr>");
				foreach (XmlNode xmlNode2 in xmlNodeList2)
				{
					string value3 = xmlNode2.Attributes["name"].Value;
					string value4 = xmlNode2.Attributes["default"].Value;
					string value5 = xmlNode2.Attributes["defIncrement"].Value;
					XmlNodeList xmlNodeList3 = xmlNode2.SelectNodes("item");
					if (xmlNodeList3 != null)
					{
						foreach (XmlNode xmlNode3 in xmlNodeList3)
						{
							stringBuilder.AppendFormat("<tr><td>{0}</td><td class='left'>{1}</td><td>{2}元</td><td>+{3}元</td></tr>", new object[]
							{
								value3,
								xmlNode3.SelectSingleNode("area").InnerXml,
								xmlNode3.SelectSingleNode("price").InnerXml,
								xmlNode3.SelectSingleNode("increment").InnerXml
							});
						}
					}
					stringBuilder.AppendFormat("<tr><td>{0}</td><td class='left'>{1}</td><td>{2}元</td><td>+{3}元</td></tr>", new object[]
					{
						value3,
						"其它",
						value4,
						value5
					});
				}
				stringBuilder.AppendFormat("<tr><td colspan=\"4\" class='left'><span>运费说明：</span>{0}</td></tr>", Intro);
				stringBuilder.Append("</table>");
			}
		}
		result = stringBuilder.ToString();
		return result;
	}
}
